package com.ctshk.rpc.hotel.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.hotel.dto.HotelRoomTypeManagerListDTO;
import com.ctshk.rpc.hotel.entity.HotelRoomType;
import com.ctshk.rpc.hotel.req.HotelRoomTypeManagerListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 酒店房型 Mapper 接口
 * </p>
 *
 * @author yinhuan
 * @since 2021-03-03
 */
public interface HotelRoomTypeMapper extends BaseMapper<HotelRoomType> {
    /**
     * 酒店查询列表
     *
     * @param req 入参
     * @return
     */
    @Select("<script>"+
            "SELECT\n" +
            "\thrt.`id`,\n" +
            "\thrt.`id` as room_id,\n" +
            "\thrt.`name`,\n" +
            "\thrt.en_name,\n" +
            "\thrt.cover_img,\n" +
            "\thrt.area_measure,\n" +
            "\thrt.bed_type,\n" +
            "\thrt.allow_smoke ,\n" +
            "\thrt.can_add_bed ,\n" +
            "\thrt.max_adult ,\n" +
            "\thrt.room_floors ,\n" +
            "\thrt.has_window ,\n" +
            "\thrt.net_type ,\n" +
            "\thrt.hotel_id ,\n" +
            "\thrt.cost_description ,\n" +
            "\thrt.facilities \n" +
            "from \n" +
            "t_hotel_room_type hrt LEFT JOIN t_hotel h on (h.id =hrt.hotel_id)"+
            "where 1=1 "+
            "<if test=\"req.brandName != null and req.brandName != ''\"> and (h.brand_name LIKE CONCAT('%',#{req.brandName},'%'))</if> \n"+
            "<if test=\"req.hotelName != null and req.hotelName != ''\"> and (h.name LIKE CONCAT('%',#{req.hotelName},'%'))</if> \n"+
            "<if test=\"req.hotelId != null and req.hotelId != ''\"> and (h.id =  #{req.hotelId} )</if> \n"+
            "</script>")
    IPage<HotelRoomTypeManagerListDTO> queryList(@Param("req") HotelRoomTypeManagerListReq req, IPage<HotelRoomTypeManagerListDTO> agentPage);
}
